package org.example;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.example.bean.ConsumerComponent;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.Scanner;

public class ConsumerMainAnno {

    public static void main(String[] args) throws Exception {

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);

        //获取消费者组件
        ConsumerComponent bean = context.getBean(ConsumerComponent.class);
        while (true) {
            Scanner scanner = new Scanner(System.in);
            System.out.println(bean.sayHello(scanner.nextLine()));

        }


    }


    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan(basePackages = "org.example")
    @EnableDubbo
    static class ConsumerConfiguration {
    }


}
